﻿using System;
using UnityEngine;

// Token: 0x0200012A RID: 298
public class AnimeLipSync_Honey : MonoBehaviour
{
	// Token: 0x060006BE RID: 1726 RVA: 0x00028074 File Offset: 0x00026274
	private void Start()
	{
		this.analyser = new AudioVolumeAnalyzer();
		this.analyser.SetAudio(this.audio);
	}

	// Token: 0x060006BF RID: 1727 RVA: 0x00028094 File Offset: 0x00026294
	private void Update()
	{
		float num = this.analyser.AnalyzeSound(0.1f);
		float time = num * this.volMul;
		float num2 = this.volToMouth.Evaluate(time);
		float value = this.analyser.AnalyzeSound(0f);
		this.animator.SetFloat(this.blendName, num2);
		this.animator.SetLayerWeight(this.layerNo, 0f);
		float num3 = Mathf.Abs(num2 - this.prevVol);
		this.mouthHCycle += num3 * 3.1415927f * this.mouthHSpeed;
		float num4 = Mathf.Abs(Mathf.Sin(this.mouthHCycle)) * num2;
		num4 = Mathf.Lerp(1f, this.mouthHMax, num4);
		this.mouthH.localScale = new Vector3(num4, 1f, 1f);
		if (this.volumeLine)
		{
			this.volumeLine.Add(num);
		}
		if (this.blendLine)
		{
			this.blendLine.Add(num2);
		}
		if (this.rawLine)
		{
			this.rawLine.Add(value);
		}
		this.prevVol = num2;
	}

	// Token: 0x0400069A RID: 1690
	public AudioSource audio;

	// Token: 0x0400069B RID: 1691
	public Animator animator;

	// Token: 0x0400069C RID: 1692
	public string blendName = "Blend";

	// Token: 0x0400069D RID: 1693
	public int layerNo;

	// Token: 0x0400069E RID: 1694
	public Transform mouthH;

	// Token: 0x0400069F RID: 1695
	public float mouthHMax = 0.5f;

	// Token: 0x040006A0 RID: 1696
	public float mouthHSpeed = 2f;

	// Token: 0x040006A1 RID: 1697
	private float mouthHCycle;

	// Token: 0x040006A2 RID: 1698
	private AudioVolumeAnalyzer analyser;

	// Token: 0x040006A3 RID: 1699
	private float prevVol;

	// Token: 0x040006A4 RID: 1700
	public float volMul = 1f;

	// Token: 0x040006A5 RID: 1701
	public AnimationCurve volToMouth;

	// Token: 0x040006A6 RID: 1702
	public LogLine volumeLine;

	// Token: 0x040006A7 RID: 1703
	public LogLine blendLine;

	// Token: 0x040006A8 RID: 1704
	public LogLine rawLine;
}
